if(checkLogin()){
	toLogin("?html=mList.html")
}



var pageNow = 1
var ttt = 1

//设置页码显示的样式
function setPager(pageInfo){
	var str=""
	var nextPager = pageInfo.nextPage
	var prePager = pageInfo.prePage
	var pages = pageInfo.pages
	var pageNumb = pageInfo.pageNum
	var start = pageNumb - 2
	var end = pageNumb + 2
	//alert(pageNumb+":"+end)
	if(prePager == 0){
		prePager = 1
	}
	if(pageInfo.nextPage == 0){
		nextPager = pages
	}
	str+='<div class="testtest"><a href="#" title="1" onclick="sendPager(1)">首页</a>'
	str+='<span class="disabled" title="上一页" onclick="sendPager('+prePager+')">上一页 </span>'
	if(start <=0){
		start = 1
		end += 2 
	}
	if(end > pages){
		start = start - (end - pages)
		if(start <= 0){
			start = 1
		}
		end = pages
	}
	if(end - start > 4){
		end = start + 4
	}
	
	for(start; start<=end ;start++){
		if(start == ttt){
			str+='<span class="current" style="background-color: #0061A6;" title="1" onclick="sendPager('+start+')">'+start+'</span>'
		}else{
			str+='<span class="current" title="1" onclick="sendPager('+start+')">'+start+'</span>'
		}
		  
		
	}
	
	
	//'<span class="current" title="1">1</span><a href="#" title="2">2</a><a href="#" title="3">3</a>'
	str+='<a href="#" title="2" onclick="sendPager('+nextPager+')">下一页 </a><a href="#" onclick="sendPager('+pageInfo.lastPage+')">尾页</a></div>'
	//alert(str)
	$('.Pagination').html(str)
	
	
}

//页码被单击
function sendPager(pag){
	pageNow = pag
	ttt = pag
	page()
}


function page(){
		
	//alert("page")
		$.ajax({
			url:path+'companyPosition/recommendationPosition',
			type:'POST',
			data:JSON.stringify({"pageNow": pageNow}),
			dataType:'json',
			crossDomain: true,
			xhrFields: {
			withCredentials: true
			},
			async: false,
			contentType: 'application/json'
		}).done(function(data){
			
			
			if(data.success){
				ll = data.length
				cc= data.company
				pp = data.position
				rr = data.rate
				str = ""
				
				for(var i = 0; i < ll; i++){
					
					c = cc[i]
					p = pp[i]
					r = rr[i]
					
					str += `
					<li class="clearfix">
						<div class="hot_pos_l">
							<div class="mb10">
								<a target="_blank" href="jobdetail.html?id=${p.id}">${p.positionType}、${p.positionName}</a>
								&nbsp;
								<span class="c9">[${p.workAddress}]</span>
							</div>
							<span><em class="c7">月薪：</em> ${p.salaryMin}k-${p.salaryMax}k</span>
							<span><em class="c7">经验：</em> ${p.workYear}</span>
							<span><em class="c7">最低学历：</em> ${p.education}</span>
							<br>
							<span><em class="c7">职位诱惑：</em> ${p.positionAdvantage}</span>
							<br>
							<span>1天前发布</span>
							<!-- <a  class="wb">分享到微博</a> -->
						</div>
						<div class="hot_pos_r">
							<div class="mb10 recompany"><a target="_blank" href="viewCompany.html?id=${c.userId}">${c.name}</a></div>
							<span><em class="c7">领域：</em> ${c.domain}</span>
							<br>
							<span><em class="c7">阶段：</em> ${c.development}</span>
							<span><em class="c7">规模：</em> ${c.scale}</span>
							<ul class="companyTags reset">
								<li>股票期权</li>
								<li>专项奖金</li>
								<li>年底双薪</li>
							</ul>
						</div>
						<div class="recommend">
							${r}
							<span>该职位与你的简历匹配度是${r} </span>
						</div>
					</li>
					
					`
				}
				
				$("#viewList").html(str)
			}else{
				$("#viewList").html('<li class="clearfix"><div>暂无推荐</div></li>')
				//alert(data.msg)
			}
			
			setPager(data.page)
			
		});
	}


$(function(){
	if(checkUserType() == 1){
		location.href="index.html"
	}
	page()
	

})



